import ctypes
import ctypes.wintypes
import sys
from PySide2.QtWidgets import QApplication, QMainWindow
from PySide2.QtUiTools import QUiLoader
from PySide2.QtWidgets import *
from PySide2.QtCore import *
from PySide2 import QtCore
from PySide2.QtGui import *
from PySide2.QtSvg import *
from PySide2 import QtGui,QtWidgets
import sys
sys.path.insert(0, 'ui')

from ui.test_ui import Ui_Frame
from src.svg_icon import SvgWidget
from ui.mainWindow import FrameLessWindow
from ui.myUiWidget import *

class MainWindow(FrameLessWindow):
    def __init__(self) -> None:
        super().__init__()
        self.initUi()

        # 加载聊天列表
        loader = QUiLoader()
        file = QtCore.QFile(r"ui\chatItemWidget.ui")
        file.open(QtCore.QFile.ReadOnly)
        widget = loader.load(file, self)
        widget.name.setText('widget')
        file.close()
        
        self.chatItemListLayout.addWidget(widget)
        
        for i in range(50,500,30):
            widget2 = ChatItemFrame('widget' + str(i))
            self.chatItemListLayout.addWidget(widget2)

        msg_other = MsgItemOtherWidget()
        msg_other.show()
        # self.msgVerticalLayout.addWidget(msg_other)
        
        # widget3 = ChatItemFrame('widget3')
        # self.chatItemListLayout.addWidget(widget3)

    def initUi(self):
        self.splitter.setSizes([581, 168])

        searchIcon = SvgWidget(":/icon/icon/search-line.svg",color=QColor(102,102,102), size=QSize(16,16))
        searchAction = QAction(self.searchLineEdit)
        searchAction.setIcon(searchIcon.get_QIcon())
        self.searchLineEdit.addAction(searchAction, QLineEdit.LeadingPosition)
        self.show()
        
        

class TestWin(Ui_Frame, QFrame):
    def __init__(self) -> None:
        super().__init__()
        self.setupUi(self)
        

if __name__ == '__main__':
    app = QApplication(sys.argv)
    mainWindows = MainWindow()
    t = TestWin()
    app.exec_()